
import VueRouter from "vue-router";

const routes = [
    {
        path:'/login',
        name:'login',
        component:()=>import("../components/Login"),

    },
    {
        path:'/Index',
        name:'index',
        component:()=>import("../components/Index"),

        //子路由
        children:[
            {
            path:'/Home',
            name:'home',
            meta:{
              title:'首页'
            },
            component: ()=>import("../components/Home")
        },/*{
                path:'/AdminManger',
                name:'admin',
                meta:{
                    title:'管理员管理'
                },
                component: ()=>import("../components/admin/AdminManage.vue")
            },            {
                path: '/UserManger',
                name: 'user',
                meta: {
                    title: '用户管理'
                },
                component: ()=>import("../components/user/UserManage.vue")
            },*/
        ]
    }
]

const router = new VueRouter({
    mode:'history',
    // base: process.env.BASE_URL,
    routes
})

export function resetRouter() {
    router.matcher = new VueRouter({
        mode: 'history',
        routes: [],
    }).matcher
}

const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
    return VueRouterPush.call(this, to).catch(err => err)
}

export default router;